package com.econ.powercloud.ems.service.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.econ.powercloud.ems.dal.entity.EmsAreaTimeSection;
import com.econ.powercloud.ems.dal.mapper.EmsAreaTimeSectionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Objects;

/**
 * @ Description:
 * @ Author：hgp
 * @ Create:2023-02-16-9:05
 */
@Repository
public class EmsAreaTimeSectionDAO extends ServiceImpl<EmsAreaTimeSectionMapper, EmsAreaTimeSection> {

    public List<EmsAreaTimeSection> selectListByCondition(Long time, Integer cityId, Integer provinceId) {
        LambdaQueryWrapper<EmsAreaTimeSection> wrapper = Wrappers.<EmsAreaTimeSection>lambdaQuery()
                .le(Objects.nonNull(time), EmsAreaTimeSection::getActiveTime, time)
                .ge(Objects.nonNull(time), EmsAreaTimeSection::getQuitTime, time)
                .eq(Objects.nonNull(cityId),EmsAreaTimeSection::getCity,cityId)
                .eq(Objects.nonNull(provinceId),EmsAreaTimeSection::getProvince,provinceId);
        return this.getBaseMapper().selectList(wrapper);
    }
}
